package org.bookie.framework.components;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;

/**
 * Component that output the number as it should be according to the
 * user locale
 * 
 * @author zubairov
 *
 */
public abstract class InsertNumber extends CommonInsert implements PageBeginRenderListener {
	
	/**
	 * Set the format accordingly
	 */
	public void pageBeginRender(PageEvent event) {
		NumberFormat numberFormat = NumberFormat.getNumberInstance(getPage().getLocale());
		numberFormat.setMinimumFractionDigits(2);
		numberFormat.setMaximumFractionDigits(2);
		((DecimalFormat)numberFormat).setDecimalSeparatorAlwaysShown(true);
		setFormat(numberFormat);
	}
	
}
